#pragma once
#include <iostream>
#include <functional>
#include<ctime>
#include <unordered_map>
using task_t=std::function<void()>;
void DownLoad()
{
    std::cout<<"正在下载...."<<std::endl;
}
void Log()
{
    std::cout<<"正在上传日志..."<<std::endl;
}
void Sql()
{
    std::cout<<"正在同步数据库数据..."<<std::endl;
}
class TaskManager
{
public:
    static int number;
    TaskManager()
    {
        srand(time(nullptr));

        InsertTask(DownLoad);
        InsertTask(Log);
        InsertTask(Sql);
    }
    void InsertTask(task_t task)
    {
        _tasks[number++]=task;
    }

    int SelectTask()
    {
        return rand()%number; 
    }
    void Excute(int number)
    {
        if(_tasks.find(number)==_tasks.end()) return ;
        _tasks[number]();
    }
    ~TaskManager()
    {

    }
private:
    std::unordered_map<int,task_t> _tasks;
};
int TaskManager::number=0;
TaskManager tm;